const tokenMiddleware = require('../../middleware/token.Middleware')
const resultFormatMiddleware = require('../../middleware/resultFormat.Middleware')
const goodsController = require("../../controller/goods.controller");


class GoodsRouter {
    constructor(router) {
        router.post('/goods/list', tokenMiddleware.verifyMiddleware, async function (req, res) {
            let [raw] = await goodsController.getGoodsList(req)
            raw.length > 0 ? resultFormatMiddleware.success(res, 'ok', 200, raw) : resultFormatMiddleware.fail(res, '暂无商品数据', 200, raw)
        })
        router.post('/goods/total', tokenMiddleware.verifyMiddleware, async function (req, res) {
            let [raw] = await goodsController.getGoodsTotal()
            raw.length > 0 ? resultFormatMiddleware.success(res, '获取total成功', 200, raw) : resultFormatMiddleware.fail(res, '暂无商品数据', 200, raw)
        })
    }
}

module.exports = GoodsRouter
